package org.gpp.proj1.robot.action.step;

import java.util.List;

import org.gpp.proj1.robot.Robot;
import org.gpp.proj1.robot.part.EquippedPart;

import com.jme.util.LoggingSystem;

/**
 * 
 * @author Gustavo de Farias
 */
public class DelayActionStep implements ActionStep {

	/**
	 * The delay
	 */
	private long milliseconds;
	
	/**
	 * @param milliseconds The delay time, in milliseconds
	 */
	public DelayActionStep(long milliseconds) {
		
		this.milliseconds = milliseconds;
	}
	
	/**
	 * @see org.gpp.proj1.robot.action.step.ActionStep#execute()
	 */
	public void execute( EquippedPart part, List<Robot> targets ) {
		this.execute( part );
	}
	
	/**
	 * @return
	 */
	public long getMilliseconds() {
		return milliseconds;
	}

	/* (non-Javadoc)
	 * @see org.gpp.proj1.robot.action.step.ActionStep#execute(org.gpp.proj1.robot.part.EquippedPart)
	 */
	public void execute( EquippedPart parent ) {
		try {
			Thread.sleep(this.milliseconds);
			
		} catch (InterruptedException e) {
			
			LoggingSystem.getLogger().warning("Delay action has failed.");
		}
	}
}
